Fix incremental loading of xbms. (#346427, Ed Catmur) Also make the xbm
authorMatthias Clasen <mclasen@redhat.com>
Mon, 17 Jul 2006 01:57:56 +0000 (01:57 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 17 Jul 2006 01:57:56 +0000 (01:57 +0000)
2006-07-16  Matthias Clasen  <mclasen@redhat.com>

* io-xbm.c: Fix incremental loading of
xbms.  (#346427, Ed Catmur)
Also make the xbm loader accept const variations.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-xbm.c

index fe6b021695bfbf5a74d88a52e62a8c8b949e181c..a0624ad311517651339489debc2b4d668b9d3138 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-16  Matthias Clasen  <mclasen@redhat.com>
+
+       * io-xbm.c: Fix incremental loading of 
+       xbms.  (#346427, Ed Catmur)
+       Also make the xbm loader accept const variations.
+
 2006-07-02  Matthias Clasen  <mclasen@redhat.com>
        
        * === Released 2.10.0 ===
index 5fe2cafdd0a3d3d83805f4d60c02dccc298c6de2..19d0e20d5d4204e7c73ca8bf8e1282a4ffc66b26 100644 (file)
@@ -143,10 +143,12 @@ next_int (FILE *fstream)
 }
 
 static gboolean
-read_bitmap_file_data (FILE *fstream,
-                      guint *width, guint *height,
+read_bitmap_file_data (FILE    *fstream,
+                      guint   *width, 
+                      guint   *height,
                       guchar **data,
-                      int *x_hot, int *y_hot)
+                      int     *x_hot, 
+                      int     *y_hot)
 {
        guchar *bits = NULL;            /* working variable */
        char line[MAX_SIZE];            /* input line from file */
@@ -198,8 +200,12 @@ read_bitmap_file_data (FILE *fstream,
     
                if (sscanf (line, "static short %s = {", name_and_type) == 1)
                        version10p = 1;
+               else if (sscanf (line,"static const unsigned char %s = {",name_and_type) == 1)
+                       version10p = 0;
                else if (sscanf (line,"static unsigned char %s = {",name_and_type) == 1)
                        version10p = 0;
+               else if (sscanf (line, "static const char %s = {", name_and_type) == 1)
+                       version10p = 0;
                else if (sscanf (line, "static char %s = {", name_and_type) == 1)
                        version10p = 0;
                else
@@ -267,7 +273,9 @@ read_bitmap_file_data (FILE *fstream,
 \f
 
 static GdkPixbuf *
-gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
+gdk_pixbuf__xbm_image_load_real (FILE     *f, 
+                                XBMData  *context, 
+                                GError  **error)
 {
        guint w, h;
        int x_hot, y_hot;
@@ -340,8 +348,6 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
        if (context) {
                if (context->update_func)
                        (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data);
-               g_object_unref (pixbuf);
-               pixbuf = NULL;
        }
 
        return pixbuf;
@@ -351,7 +357,8 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
 /* Static loader */
 
 static GdkPixbuf *
-gdk_pixbuf__xbm_image_load (FILE *f, GError **error)
+gdk_pixbuf__xbm_image_load (FILE    *f, 
+                           GError **error)
 {
        return gdk_pixbuf__xbm_image_load_real (f, NULL, error);
 }
@@ -365,11 +372,11 @@ gdk_pixbuf__xbm_image_load (FILE *f, GError **error)
  */
 
 static gpointer
-gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
-                                  GdkPixbufModulePreparedFunc prepare_func,
-                                 GdkPixbufModuleUpdatedFunc update_func,
-                                 gpointer user_data,
-                                 GError **error)
+gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc       size_func,
+                                  GdkPixbufModulePreparedFunc   prepare_func,
+                                 GdkPixbufModuleUpdatedFunc    update_func,
+                                 gpointer                      user_data,
+                                 GError                      **error)
 {
        XBMData *context;
        gint fd;
@@ -398,8 +405,8 @@ gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
 }
 
 static gboolean
-gdk_pixbuf__xbm_image_stop_load (gpointer data,
-                                 GError **error)
+gdk_pixbuf__xbm_image_stop_load (gpointer   data,
+                                 GError   **error)
 {
        XBMData *context = (XBMData*) data;
         gboolean retval = TRUE;
@@ -410,10 +417,13 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data,
        rewind (context->file);
        if (context->all_okay) {
                 GdkPixbuf *pixbuf;
-                pixbuf = gdk_pixbuf__xbm_image_load_real (context->file, context,
+                pixbuf = gdk_pixbuf__xbm_image_load_real (context->file, 
+                                                         context,
                                                           error);
                 if (pixbuf == NULL)
                         retval = FALSE;
+               else
+                       g_object_unref (pixbuf);
         }
 
        fclose (context->file);
@@ -425,10 +435,10 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data,
 }
 
 static gboolean
-gdk_pixbuf__xbm_image_load_increment (gpointer data,
+gdk_pixbuf__xbm_image_load_increment (gpointer       data,
                                       const guchar  *buf,
-                                      guint    size,
-                                      GError **error)
+                                      guint          size,
+                                      GError       **error)
 {
        XBMData *context = (XBMData *) data;